home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / LISTINGS / V_13_07 / ROSS / FCLFFIND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-30  |  525 b   |  25 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. int fclfFind(int n, char *txt, int m, char *pat, int pos)
  4. { int i, j, k;
  5.   int nmatch = 0;
  6.   char *cp;
  7.   cp = strchr(txt, pat[pos]);
  8.   while (cp)
  9.   { i = cp - txt;
  10.     k = i - pos;
  11.     for (j=0; j<m && txt[k] == pat[j]; j++)
  12.  k++;
  13.     if (j == m)
  14.     { nmatch++;
  15.  printf("%d \n", i-pos);
  16.  cp = strchr(txt+i+m, pat[pos]);
  17.     }
  18.     else
  19.  cp = strchr(txt+i+1, pat[pos]);
  20.   }
  21.   return(nmatch);
  22. }
  23. Figure 5. First character, low frequency string searching function.
  24.  
  25.